<style lang="scss" scoped>
	.content{
		width:100%;
		background-color: white;
		padding:30rpx 0;
	}
	.list{
		padding:25rpx;
		border-bottom: 1px solid #ccc;
		align-items: flex-start;
		color: #737373;
		.red{
			transform: translateY(6rpx);
		}
		.textarea{
			width:460rpx;
			height:120rpx;
			font-size: 28rpx;
		}
		.mic{
			height:120rpx;
			width:80rpx;
			border-left: 1px solid #ccc;
			padding-left:20rpx;
		}
		.ipt{
			width:550rpx;
		}
		.uploadfile{
			width:550rpx;
			.btns{
				width:100%;
				.btn{
					width: 152rpx;
					height: 64rpx;
					
					border: 2rpx solid #bfbfbf;
					border-radius: 34rpx;
				}
			}
		}
		.record{
			width:550rpx;
		}
	}
</style>

<template>
	<view class="content">
		<view class="f34 bold" style="padding:0 30rpx;border-bottom: 1px solid #ccc;padding-bottom: 20rpx;">暂停处理</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				暂停原因
			</view>
		<picker mode="selector" :range="dic.suspendReason" range-key="name"
			@change="choose($event,1,dic.suspendReason)">
			<view class="align-flex blue choosearea">
				{{reason?reason.name:'请选择'}}
				<u-icon name="arrow-right" color="#409EFF" size="28"></u-icon>
			</view>
		</picker>
		</view>
	
		<view class="list between-flex f28">
			<view class="align-flex">
				详细说明
			</view>
			<view class="align-flex ">
				<textarea style="width:550rpx;" class="textarea" v-model="remark" maxlength="-1" placeholder="请填写" />
				
			</view>
		</view>
		
		<view class="list between-flex f28">
			<view class="align-flex">
				附件
			</view>
			<view class="uploadfile">
				<view class="btns align-flex m-bottom20">
					<view class="btn center-flex c666 " @click="uploadfile" style="margin-right: 40rpx;">上传</view>
					<view class="btn center-flex bgblue cfff" @click="chooseImg">拍照</view>
				</view>
				<view class="p-top10 between-flex" v-for="item,index in enclosure" :key="index">
					<view class="align-flex blue" @click="$open(item.url)">
						<u-icon name="file-text" color="#409EFF" size="38" ></u-icon>
						{{item.fileName.substring(item.fileName.length-10)}}
					</view>
					<u-icon @click="delfile(index)" name="close" color="#666666" size="30"></u-icon>
				</view>
			</view>
		</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				暂停时间
			</view>
			<view class="align-flex " style="width: 550rpx;">
				{{date}}
			</view>
		</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				处理人
			</view>
			<view class="align-flex " style="width: 550rpx;">
					{{username}}
			</view>
		</view>
		<view class="lbtn" @click="submit()">确认</view>
	</view>
</template>

<script>
	
	export default {
		props: {
			orderNum: {
				default: ''
			}
		},
		data(){
			return{
				head:this.$head,
				date:'',
				username:'',
				remark: '',
				dic: uni.getStorageSync('dic'),
				enclosure: [],
				reason:null
			}
		},
		created() {
			this.date=this.$getDate()
			this.username=uni.getStorageSync('username')
			
		},
		methods: {
			delfile(index) {
				this.enclosure.splice(index, 1)
			},
			choose(e, type, list) {
			
				switch (type) {
					case 1:
						this.reason = list[e.detail.value];
						break;
					
				}
				
			},
			
			//选择图片
			async chooseImg() {
			
				var file = await this.$chooseImg()
			
				this.enclosure.push(file)
			
			},
			async uploadfile() {
			
				var file = await this.$uploadfile()
				this.enclosure.push(file)
			
			},
			submit() {
				if (!this.reason) {
					this.$msg('请选择暂停原因')
					return
				}
				
				uni.showLoading({
					title: '提交中...'
				})
				var obj = {
					orderNum: this.orderNum,
					remark: this.remark,
					processValue:this.reason.value
				}
				if (this.enclosure.length > 0) {
					var enclosure = []
					this.enclosure.forEach(item => {
						enclosure.push({
							name: item.oldName,
							url: item.url
						})
					})
					obj['processEnclosure'] = JSON.stringify(enclosure)
				}
				this.$pop.ajaxPost('/wechat/order/suspend', obj).then(res => {
					uni.hideLoading()
					if (res.code == 0) {
						this.$msg('提交成功')
						this.$emit('submit')
					} 
				})
			},
			

		}
	}
</script>

